//
//  SettlementTableViewCell.m
//  HarmonizePub
//
//  Created by rzhy on 16/9/5.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "SettlementTableViewCell.h"
#import "Config.h"
#import "Settlement.h"

@interface SettlementTableViewCell ()

@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *medicalCardLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *timerLabel;
@property (weak, nonatomic) IBOutlet UILabel *depLabel;
@property (weak, nonatomic) IBOutlet UILabel *jobLabel;
@property (weak, nonatomic) IBOutlet UILabel *docLabel;
@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;
@property (weak, nonatomic) IBOutlet UIButton *paymentButton;

@end

@implementation SettlementTableViewCell

+ (NSString *)registerName {
    return @"SettlementTableViewCell";
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.bgView.layer.cornerRadius = 8.0;
    self.bgView.layer.masksToBounds = YES;
    self.bgView.layer.borderWidth = 0.5f;
    self.bgView.layer.borderColor = XHConfigColor.CGColor;
    self.paymentButton.layer.cornerRadius = 5.0f;
    self.paymentButton.layer.masksToBounds = YES;
}

- (void)setSettlement:(Settlement *)settlement {
    _settlement = settlement;
    self.nameLabel.text        = settlement.name;
    self.medicalCardLabel.text = settlement.medicalCard;
    self.orderNumberLabel.text = settlement.orderNumber;
    self.timerLabel.text       = settlement.timer;
    self.depLabel.text         = settlement.dep;
    self.jobLabel.text         = settlement.job;
    self.docLabel.text         = settlement.doc;
    self.moneyLabel.text       = settlement.money;
}

#pragma mark - 支付
- (IBAction)paymentEvent:(UIButton *)sender {
    if ([self.cellDelegate respondsToSelector:@selector(tableViewCell:didPaymentEventAtSettlement:)])
        [self.cellDelegate tableViewCell:self didPaymentEventAtSettlement:self.settlement];
}

- (void)setPaymentState:(BOOL)paymentState {
    _paymentState = paymentState;
    self.paymentButton.enabled = !paymentState;
    if (paymentState) {
        [self.paymentButton setTitle:@"已支付" forState:UIControlStateNormal];
        [self.paymentButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.paymentButton.backgroundColor = [UIColor lightGrayColor];
    } else {
        [self.paymentButton setTitle:@"支付" forState:UIControlStateNormal];
        [self.paymentButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.paymentButton.backgroundColor = RGBAColor(125, 26, 31, 0.7);
    }
}

+ (CGFloat)cellHeight {
    return 280.0f;
}

@end
